
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>购物车-阿福易购</title>
    <meta name="keywords" content="{{$SEO['keywords']}}"/>
    <meta name="description" content="{{$SEO['description']}}"/>

    <!--公用css引用-->
    @include('front.common.style')

            <!--END/公用css引用-->
    <link rel="stylesheet" href="{{asset('/dist/css/index.css')}}">
    <link rel="stylesheet" href="../dist/css/userCenter.css">
</head>
<body>

<!--公共头部-->
@include('front.common.header')
<!--END/公共头部-->

@inject('cartService','App\Interfaces\CartService')
@inject('pictureService','App\Interfaces\PictureService')
@inject('goodsService','App\Interfaces\GoodsService')
@inject('discountService','App\Interfaces\DiscountService')

    <?php
        $randomGoods = $goodsService->getRandomGoods(20);
        $cartGoods = $cartService->getCartGoods();
        $getInfo = $cartService->getInfo();

            if(!$getInfo){
                header("location: {{env('URL')}}");
            }//end if()
?>



<!--购物车列表-->
<div class="inbox2">
    <div class="ui-box1 fn-mt20">
        <div id="js-focusOn" class="tit-4 tit-skin-1">
            <h1 class="h">全部商品</h1>
        </div>

        <div id="listSelect" class="cart-list">

        @if($cart['total_number'])
            <table class="bl-table bl-table-brdli table-tc list-title">
                <thead>
                <tr class="js-tools">
                    <th class="tl w-100">
                        <label><input class="js-selectAll" type="checkbox" checked>全选</label>
                    </th>
                    <th colspan="2" class="tl">商品信息</th>
                    <th class="w-100">单价（元）</th>
                    <th class="w-120">数量</th>
                    <th class="w-100">小计（元）</th>
                    <th class="w-100">操作</th>
                </tr>
                </thead>
            </table>

            <!--普通商品-->
            @if($cart['cshopGoods']['total_number']>0)
            <table class="js-viewBox bl-table bl-table-brdli table-tc list-body">
                <tr class="table-inner-head table-inner-tr">
                    <td class="checkbox" colspan="8">
                        <label><input class="js-selectOneList" type="checkbox" checked></label>
                        <span class="bl-label label-def">免税商品</span>
                    </td>
                </tr>


                @foreach($cart['cshopGoods']['shopGoods'] as $goodsIndex=>$goods)
                    <?php /*$getCanUseBiggestDiscountByGoodsId = @$discountService->getCanUseBiggestDiscountByGoodsId(@$goods->goods_id);

                        if($getCanUseBiggestDiscountByGoodsId){
                            $goods_real_price = sprintf("%.2f",sprintf("%.3f", $goods['shop_price']*$getCanUseBiggestDiscountByGoodsId->discount_value/100));
                        }else{
                            $goods_real_price = sprintf("%.2f",sprintf("%.3f", $goods['shop_price']));
                        }*/
                    ?>

                    <tr class="list-item @if(!empty($goods['deleted_at']) || $goods['is_on_sale']==2 || $goods['goods_number']==0) disabled-item @else selected @endif" data-id="{{$goods['goods_id']}}" data-price="{{$goods['goods_real_price']}}" data-num="{{$goods['buy_num']}}">
                        <td class="checkbox">
                            <label for=""><input class="js-checkbox" type="checkbox" @if(!empty($goods['deleted_at']) || $goods['is_on_sale']==2 || $goods['goods_number']==0) disabled @else checked @endif></label>
                        </td>
                        <td class="pic tl">
                            <a href="/goods/{{$goods['goods_id']}}" target="_blank"  title="{{$goods['goods_name']}}">
                                <img class="head-img" src="{{$pictureService::thumb($goods['goods_thumb'], 70, 70)}}" alt="{{$goods['goods_name']}}">
                            </a>
                        </td>
                        <td class="tl name">
                            <p class="name"><a class="link" href="/goods/{{$goods['goods_id']}}" target="_blank" title="{{$goods['goods_name']}}">{{$goods['goods_name']}}</a></p>
                        </td>
                        <td class="params tl">
                            {{--<p class="param">颜色：我爱下雨</p>
                            <p class="param">尺码：1.8米床</p>--}}
                        </td>
                        <td class="w-100">
                                <span><del class="t-gray9">{{$goods['shop_price']}}</del><BR>{{$goods['goods_real_price']}}</span>
                        </td>
                        <td class="w-120">
                            @if(!empty($goods['deleted_at']) || $goods['is_on_sale']==2)
                                <div class="bl-label label-error">该商品已下架</div>
                            @elseif($goods['goods_number']==0)
                                <p class="text-color-1">库存不足</p>
                            @else
                                <div class="num-tool fn-dib">
                                    <div class="r-btn">＋</div>
                                    <div class="l-btn">－</div>
                                    <input class="num-input" type="text" value="{{$goods['buy_num']}}" min="1" max="{{$goods['goods_number']}}" readonly>
                                </div>
                                @if($goods['goods_number'] < 10)
                                    <p class="text-color-1">库存{{$goods['goods_number']}}件</p>
                                @endif
                            @endif


                        <td class="w-100">
                            <span class="js-singlePay">{{sprintf("%.2f",sprintf("%.3f", $goods['goods_real_price'] * $goods['buy_num']))}}</span>
                        </td>
                        <td class="w-100">
                            <a class="js-del" href="#">删除</a>
                        </td>
                    </tr>

                @endforeach


            </table>
            @endif

            <!--E贸易商品-->
            @if($cart['eshopGoods']['total_number'])

            <?php
                $onSaleNum=0;

                //遍历E贸易商品中的非下架商品
                if($cart['eshopGoods']['total_number']>1&&$cart['eshopGoods']['total_price']>1000){
                    foreach($cart['eshopGoods']['shopGoods'] as $curGoods){
                        if( $curGoods['deleted_at']|| $curGoods['is_on_sale']==2 || $curGoods['goods_number'] == 0){
                            continue;
                        }
                        $onSaleNum=$onSaleNum+$curGoods['buy_num'];
                    }
                }

                $showTotalWarning=$onSaleNum>1;
            ?>

            <!--E贸易商品-->
            <table id="eShopTable" class="js-viewBox bl-table bl-table-brdli table-tc list-body @if($showTotalWarning) cart-danger @endif">
                <tr class="table-inner-head table-inner-tr">
                    <td class="checkbox" colspan="8">
                        <label><input class="js-selectOneList" type="checkbox" checked></label>
                        <span class="bl-label label-def">E贸易商品</span>
                    </td>
                </tr>


                @foreach($cart['eshopGoods']['shopGoods'] as $egoodsIndex=>$egoods)
                    <?php
                    $shuiPercent= ($egoods['excise_duty_percent']+$egoods['value_added_tax_percent'])*0.7;
                    ?>
                    <tr class="list-item @if(!empty($egoods['deleted_at']) || $egoods['is_on_sale']==2 || $egoods['goods_number']==0) disabled-item @else selected @endif" data-id="{{$egoods['goods_id']}}" data-price="{{$egoods['goods_real_price']}}" data-num="{{$egoods['buy_num']}}" data-tariff="{{$shuiPercent}}">
                        <td class="checkbox">
                            <label for=""><input class="js-checkbox" type="checkbox"  @if(!empty($egoods['deleted_at']) || $egoods['is_on_sale']==2 || $egoods['goods_number']==0) disabled @else checked @endif></label>
                        </td>
                        <td class="pic tl">
                            <a href="/goods/{{$egoods['goods_id']}}" target="_blank" title="{{$egoods['goods_name']}}">
                                <img class="head-img" src="{{$pictureService::thumb($egoods['goods_thumb'], 70, 70)}}" alt="{{$egoods['goods_name']}}">
                            </a>
                        </td>
                        <td class="tl name">
                            <p class="name"><a class="link" href="/goods/{{$egoods['goods_id']}}" target="_blank" title="{{$egoods['goods_name']}}">{{$egoods['goods_name']}}</a></p>
                            <div class="fn-mt4">
                                <div class="gs-tip fn-rel fn-dib- fn-hide">

                                    <span>适用税率 : {{$shuiPercent}}% <i class="icon icon-arrow-b1"></i></span>
                                    <div class=" bl-tip-box tip-skin-gray">
                                        <div class="J-box TJ-box"><span class="J"></span><i class="J"></i></div>
                                        <div class="mask-T"></div>
                                        <div class="bl-tip-con" style="font-size: 12px;">
                                            <div>
                                                <p>海关规定：</p>
                                                <ul>
                                                    <li class="text-color-1 fn-mb4 fn-mt4">税费 = 不含税价格 × 件数 × 商品税率</li>
                                                    <li>根据海关规定，本商品适用税率 : {{$egoods['tariff_percent']}}%,若订单总税额 ≤ 50元，海关予以免征。</li>
                                                </ul>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <span class="sel-light fn-ml10-">关税：￥</span><span class="js-singleGs sel-light "><span class="js-gs">{{$egoods['tariff_price']}}</span></span>
                            </div>
                        </td>
                        <td class="params tl">
                            {{--<p class="param">颜色：我爱下雨</p>
                            <p class="param">尺码：1.8米床</p>--}}
                        </td>
                        <td class="w-100">
                            <span><del class="t-gray9">{{$egoods['shop_price']}}</del><BR>{{$egoods['goods_real_price']}}</span>
                        </td>
                        <td class="w-120">
                            @if(!empty($egoods['deleted_at']) || $egoods['is_on_sale']==2)
                                <div class="bl-label label-error">该商品已下架</div>
                            @elseif($egoods['goods_number']==0)
                                <p class="text-color-1">库存不足</p>
                            @else
                                <div class="num-tool fn-dib">
                                    <div class="r-btn">＋</div>
                                    <div class="l-btn">－</div>
                                    <input class="num-input" type="text" value="{{$egoods['buy_num']}}" min="1" max="{{$egoods['goods_number']}}" readonly>
                                </div>
                                @if($egoods['goods_number'] < 10)
                                    <p class="text-color-1">库存{{$egoods['goods_number']}}件</p>
                                @endif
                            @endif
                        <td class="w-100">
                            <span class="js-singlePay">
                                {{sprintf("%.2f",sprintf("%.3f", $egoods['goods_real_price'] * $egoods['buy_num']))}}
                            </span>
                        </td>
                        <td class="w-100">

                            <a class="js-del" href="#">删除</a>
                        </td>
                    </tr>

                @endforeach

    <!-- 这里先隐藏，后面再决定如何处理 -->
                <tr class="inner-tj @if($cart['eshopGoods']['total_tariff_price']>50) waring @endif" style="display: none !important;">
                    <td colspan="8" class="tr">

                        <del class="skin-def text-color-7">
                            <span class="fn-ml20">关税￥</span><span class="gs">{{number_format($cart['eshopGoods']['total_tariff_price'],2)}}</span>
                        </del>

                        <div class="skin-warning">
                            <strong class="danger-hide">温馨提示：关税已超出50元！只有小于等于50元时才能免征哦</strong>

                            <div class="fn-dib fn-rel fn-ml20 label-tag">
                                <span class="fn-dib label">关税</span><span class="fn-dib tag"><strong>￥</strong><strong class="gs">{{number_format($cart['eshopGoods']['total_tariff_price'],2)}}</strong></span>

                                <div class="bl-tip-box tip-skin-gray">
                                    <div class="J-box TJ-box"><span class="J"></span><i class="J"></i></div>
                                    <div class="mask-T"></div>
                                    <div class="bl-tip-con">
                                        <p>海关规定：</p>
                                        <p>个人邮寄进境物品，海关依法征收进口税，但应征进口税税额在人民币50元（含50元）以下的，海关予以免征</p>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </td>
                </tr>

                <!--单笔订单超过1000-->
                <tr class="tip-box">
                    <td colspan="8">
                        <div class="fn-tr font-14">
                            <strong>温馨提示：订单已超过海关限额 <span class="text-color-danger font-16">￥1000</span>，请选择部分商品结算</strong>
                            <div class="fn-rel fn-dib tip-more" data-pos="">
                                <i class="icon icon-tip icon-tip-1"></i>

                                <div class=" bl-tip-box tip-skin-gray">
                                    <div class="J-box TJ-box"><span class="J"></span><i class="J"></i></div>
                                    <div class="mask-T"></div>
                                    <div class="bl-tip-con">
                                        <div class="more-content">
                                            <p>海关规定：</p>
                                            <ul>
                                                <li>① 消费者购买进口商品，以“个人自用，合理数量”为原则，每单最大购买金额不得超过1000元人民币（不含关税）。</li>
                                                <li>② 如有优惠活动，则1000元限值适用于订单优惠后的金额。</li>
                                                <li>③ 如果订单只含单件不可分割商品，则可以超过1000元限制。</li>
                                            </ul>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </td>
                </tr>
            </table>
            @endif


            <!--底部-->
            <div id="listFooter" class="fn-mt20">

                <table class="bl-table bl-table-brdli table-tc list-foot" style="border-bottom: 0;">
                    <tfoot>
                    <tr class="js-tools has-select">
                        <td class="checkbox" colspan="2">
                            <label><input class="js-selectAll" type="checkbox" checked>全选</label>
                            <a class="js-del fn-ml30" data-type="all" href="#">删除选中的商品</a>
                            <!--<a class="js-fav fn-ml30" data-type="all" href="#">添加到我的收藏</a>-->
                        </td>
                        <td class="tr" colspan="2">
                            <p class="">已选择 <strong class="js-totalNum sel-light font-14">{{$cart['total_number']-$cart['total_number_not']}}</strong> 件商品</p>
                        </td>
                        <td class="total-price tr" colspan="2">
                            <p class=""><span class="w-10em fn-tr">总价（不含运费）：</span><strong class="sel-light font-16">￥<span class="js-totalPay">{{number_format($cart['pay_price'],2)}}</span></strong></p>
                            <p class="text-color-7"><span class="w-10em fn-tr">关税：</span>￥ <span class="js-totalGs">{{number_format($cart['total_tariff_price'],2)}}</span></p>
                        </td>
                        <td class="pay-btn-wrap">
                            <button class="pay-btn btn-primary js-payment">结 算</button>
                        </td>
                    </tr>
                    </tfoot>
                </table>

            </div>

            <!--END/底部-->
        @else

        <!--我的订单 无数据-->
        <div class="ui-brd-box1">
            <div class=" bl-nodata order-nodata">
                <div class="nodata-text fn-dib">
                    <p class="fn-mb0">购物车是空的</p>
                    <a href="/">快去看看有哪些热门商品吧 &gt;</a>
                </div>
            </div>
        </div>
        <!--END/我的订单 无数据-->
        @endif
        </div>
    </div>
</div>
<!--END/购物车列表-->

<div class="inbox">
    <!--猜你喜欢-->
    <div class="js-recommend  recommend-list">
        <div class="list-head fn-mb16">
            <div class="tit tit-4">
                <h3 class="h fn-mr10">
                    猜你喜欢
                </h3>
                <div class="more fn-fl fn-mt4">
                    根据您的浏览记录推荐的商品
                </div>
                <a href="javascript:;" class="js-reloadBtn more" data-step="0"><i class="icon icon-load1"></i>换一批</a>
            </div>
        </div>
        <div class="list-body"  style="height: 268px;">
            <ul class="bl-imglist imglist-5col js-recList ui-100">

                @if($randomGoods)
                    @foreach($randomGoods as $key=>$value)
                        <?php
                        if($key<2) continue;
                        if($key>20) break;
                        ?>

                        <li style="height: 268px;">
                            <div class="col-space fn-ohide">
                                <a href="/goods/{{$value->goods_id}}" target="_blank"  title="{{$value->goods_name}}">
                                    <img class="lazy img-lazyload" style="width: 200px;height: 200px;" data-src="@if($value->goods_thumb){{$pictureService->thumb($value->goods_thumb, 200, 200)}} @else # @endif" alt="">
                                </a>
                                <div class="fn-ml4 fn-mr4">
                                    <a href="/goods/{{$value->goods_id}}" target="_blank" class="name ui-100 fn-dib-otw" title="{{$value->goods_name}}">{{$value->goods_name}}</a>
                                    <p class="price"><span>{{$value->shop_price}}</span>元</p>
                                </div>
                            </div>
                        </li>
                    @endforeach
                @endif
            </ul>
        </div>
    </div>
    <!--END/猜你喜欢-->
</div>


<!--公共尾部-->
@include('front.common.footer')
<!--END/公共尾部-->


<!--公用js引用-->
@include('front.common.script')
<!--END/公用js引用-->

<script>
    var timestamp=new Date().getTime();
    var page_global={
        edit_url:'cart/getGoodsInfo', //edit url
        del_url:'cart/'+timestamp,
        fav_url:'',
        settlement_url:'cart/pay'
    };

</script>
<script src="../dist/js/cart.js"></script>
</body>
</html>